﻿using System;
using RestSharp;

namespace Ymatou.ServiceCenter
{
    /// <summary>
    /// 用来打在Request类中，通过appId,apiName,httpMethod的组合键到服务中心中找到元数据信息。
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class ResourceAttribute : Attribute
    {
        /// <summary>
        /// 构建Http请求资源特性
        /// </summary>
        public ResourceAttribute()
        {

        }

        /// <summary>
        /// 构建资源标签
        /// </summary>
        /// <param name="appId">应用编号</param>
        /// <param name="apiName">接口名称</param>
        /// <param name="httpMethod">http方法</param>
        /// <param name="parameterBuildType">http请求参数构建类型</param>
        public ResourceAttribute(string appId, string apiName, Method httpMethod, ParameterBuildType parameterBuildType)
        {
            this.AppId = appId;
            this.ApiName = apiName;
            this.HttpMethod = httpMethod;
            this.ParameterBuildType = parameterBuildType;
        }

        /// <summary>
        /// 应用编号
        /// </summary>
        public string AppId { get; set; }

        /// <summary>
        /// 接口名称
        /// </summary>
        public string ApiName { get; set; }

        /// <summary>
        /// http方法
        /// </summary>
        public Method HttpMethod { get; set; }

        /// <summary>
        /// http请求参数构建类型
        /// </summary>
        public ParameterBuildType ParameterBuildType { get; set; }

    }

    /// <summary>
    /// 使用Uri参数的形式来构建http请求参数
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class QueryParameterAttribute : Attribute
    {

    }

    /// <summary>
    /// 通过表单参数的方式来构建http请求参
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class FormParameterAttribute : Attribute
    {

    }

    /// <summary>
    /// 如果参数上打上了[FromBody]标签的，需要在契约的请求包的类的对应属性上打上[BodyString]标签
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class BodyStringValueAttribute : Attribute
    {

    }
}
